#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
int t, n, m, l, v;
int cd[100001], cv[100001], ca[100001], p[100001][2];
int ans1, ans2;
void specialA(int x){
    if (cv[x] > v) {
        ans1 ++;
        for (int i = 1; i <= m; i ++)
            if (cd[x] >= p[i][0]) {
                p[i][1] = 1;
                break;
            }
    }
}
void specialB(int x) {
    double s = (v * v - cv[x] * cv[x]) / (double)(2 * ca[x]) + cd[x];
    if (s < p[m][0]) {
        ans1 ++;
        for (int i = 1; i <= m; i ++)
            if (cd[x] >= p[i][0]) {
                p[i][1] = 1;
                break;
            }
    }
}
signed main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> t;
    while (t --) {
        memset(p, 0, sizeof(p));
        ans1 = 0;
        ans2 = 0;
        cin >> n >> m >> l >> v;
        for (int i = 1; i <= n; i ++)
            cin >> cd[i] >> cv[i] >> ca[i];
        for (int i = 1; i <= m; i ++)
            cin >> p[i][0];
        for (int i = 1; i <= n; i ++) {
            if (ca[i] == 0) 
                specialA(i);
            else if (ca[i] > 0)
               specialB(i);
        }
        for (int i = 1; i <= m; i ++)
            if (!p[i][1])
                ans2 ++;
        cout << ans1 << " " << ans2 << "\n";
    }
    return 0;
}